package com.ysz.component.conf;

import com.ysz.component.page.MyBatisPageInterceptor;
import com.ysz.component.constant.MyBatisConst;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @ClassName MyBatisPageInterceptorConfig
 * @Description 配置mybatis的分页拦截
 * @Data 9:52
 * @Version 1.0
 * @Author ysz
 */
@Configuration
public class MyBatisPageInterceptorConfig {

    @Bean
    public Interceptor myBatisPageInterceptor() {
        Properties properties = new Properties();
        properties.setProperty(MyBatisConst.mysql_type.getKey(), MyBatisConst.mysql_type.getValue());
        properties.setProperty(MyBatisConst.page_flag.getKey(), MyBatisConst.page_flag.getValue());
        properties.setProperty(MyBatisConst.count_flag.getKey(), MyBatisConst.count_flag.getValue());
        MyBatisPageInterceptor myBatisInterceptor = new MyBatisPageInterceptor();
        myBatisInterceptor.setProperties(properties);
        return myBatisInterceptor;
    }
}
